/**
 *
 */
package com.storm.lib.base;

import java.lang.reflect.Field;

import javax.persistence.Transient;


import org.apache.log4j.Logger;

import com.storm.lib.util.ExceptionUtil;



/**
 * 类功能: 实体类的基本类
 * @author johnny
 * @version 2010-10-28
 */
public class BasePo implements java.io.Serializable{

	@Transient
	protected final Logger logger = Logger.getLogger(getClass());
	/**
	 *描述:主键
	 **/

	private Integer id;


//	private transient RoleDAO roleDAO;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * 是否已经加载
	 */
//	@JsonIgnore
	protected boolean loaded = false;

//	@JsonIgnore
	protected boolean wasChanged;

	/**
	 *
	 * 方法功能:设置属性
	 * 更新时间:2010-11-2, 作者:johnny
	 * @param name
	 * @param value
	 * @throws Exception
	 */
	public void setProperty(String name,Object value){
	     try {
			Field filed = getClass().getDeclaredField(name);
			filed.setAccessible(true);
			filed.set(this, value);
		} catch (Exception e) {
			ExceptionUtil.processException(e);
		}
	}

	/**
	 * @return the roleDAO
	 */
//	@Transient
//	protected RoleDAO getRoleDAO() {
//		return roleDAO;
//	}

	/**
	 * @param roleDAO the roleDAO to set
	 */
//	protected void setRoleDAO(RoleDAO roleDAO) {
//		this.roleDAO = roleDAO;
//	}


	/**
	 *
	 * 方法功能:加载所有"引用关系"的对象
	 * 更新时间:2010-12-28, 作者:johnny
	 */
	public void loadData(BasePo basePo){
//		if(getRoleDAO()==null){
//			setRoleDAO((RoleDAO) BeanUtil.getBean("roleDAO"));
//		}
//		loaded=false;
	}


	public void saveData() {

	}



	public void changed(Object obj1, Object obj2){
	}

	public void unChanged(){
	}

	public String fetchIdentify() {
		return this.getClass().getSimpleName()+":"+getId();
	}

	public boolean gLoaded() {
		return loaded;
	}

	public void sLoaded(boolean loaded) {
		this.loaded = loaded;
	}

	public boolean gWasChanged() {
		return wasChanged;
	}

	public void sWasChanged(boolean wasChanged) {
		this.wasChanged = wasChanged;
	}

}
